// Last Update:2015-01-27 16:16:08
/**
 * @file options.c
 * @brief 
 * @author 
 * @version 0.1.00
 * @date 2015-01-27
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <libHX/option.h>

int main(int argc, char *argv[])
{
	char *dev = NULL;
	char *smac = NULL;
	char *dmac = NULL;
	char *sip = NULL;
	char *dip = NULL;

	struct HXoption options_table[] = {
		{.sh = 'i', .ln = "interface", .type = HXTYPE_STRING, .ptr = &dev, .help = "Set interface of sending packets"},
		{.ln = "smac", .type = HXTYPE_STRING, .ptr = &smac, .help = "Set Source MAC"},
		{.ln = "dmac", .type = HXTYPE_STRING, .ptr = &dmac, .help = "Set Destination MAC"},
		{.ln = "sip", .type = HXTYPE_STRING, .ptr = &sip, .help = "Set Source IP"},
		{.ln = "dip", .type = HXTYPE_STRING, .ptr = &dip, .help = "Set Destination IP"},
		HXOPT_AUTOHELP,
		HXOPT_TABLEEND,
	};
	if (HX_getopt(options_table, &argc, (const char ***)&argv, HXOPT_USAGEONERR) !=
			HXOPT_ERR_SUCCESS)
	{
		return EXIT_FAILURE;
	}
	printf("iterface = %s, smac = %s, dmac = %s, sip = %s, dip = %s\n",
			dev, smac, dmac, sip, dip);
	while (*++argv != NULL)
	{
		printf("Non-option argument %s\n", *argv);
	}
	return 0;
}
